Aspect注解 Pointcut Annotation on Interface

本意的实现效果

@Aspect
@Component
public class MyAspect {

    @Pointcut(value = "@annotation(com.example.aoptest.demo.aop.MyAnnotation)")
    public void point() {
    }

    @Before("point()")
    public void beforeDigest(JoinPoint joinPoint) {
       //do something....
    }

}

public interface ITest {
    @MyAnnotation
    void show();
}
@Service
public class TestService implements ITest {

    @Override
    public void show() {
        System.out.println("TestService TestService TestService TestService TestService TestService TestService");
    }
}

实际情况

上述代码是不能实现的,将@MyAnnotation转移到实现类的方法上就是可以的 查了下资料缺失暂时是不能实现的。期待后续的更新吧。

//TODO

这里有篇文章:https://my.oschina.net/guangshan/blog/1808373 https://github.com/spring-projects/spring-framework/issues/22311

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×